/**
 * 
 */
package wpmp.portal;

import javax.servlet.ServletContext;

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.web.context.ServletContextAware;

/**
 * @author Wayne.Wang<5waynewang@gmail.com>
 * @since 11:48:52 AM Dec 5, 2013
 */
public class Configurations implements ServletContextAware {

	private static final Logger LOG = Logger.getLogger(Configurations.class);

	private static String mainHeaderBackgroundUrl;// 主页 头部 背景图片URL地址
	private static String mainFooterText = "googlecode";// 主页 底部 文字
	private static String pageIconUrl; // 页面图标的URL地址

	public static String getPageIconUrl() {
		return pageIconUrl;
	}

	public void setPageIconUrl(String pageIconUrl) {
		if (StringUtils.isNotBlank(pageIconUrl)) {
			Configurations.pageIconUrl = pageIconUrl;
		}

		if (LOG.isInfoEnabled()) {
			LOG.info("pageIconUrl = " + Configurations.pageIconUrl);
		}
	}

	public static String getMainHeaderBackgroundUrl() {
		return mainHeaderBackgroundUrl;
	}

	public void setMainHeaderBackgroundUrl(String mainHeaderBackgroundUrl) {
		if (StringUtils.isNotBlank(mainHeaderBackgroundUrl)) {
			Configurations.mainHeaderBackgroundUrl = mainHeaderBackgroundUrl;
		}

		if (LOG.isInfoEnabled()) {
			LOG.info("mainHeaderBackgroundUrl = " + Configurations.mainHeaderBackgroundUrl);
		}
	}

	public static String getMainFooterText() {
		return mainFooterText;
	}

	public void setMainFooterText(String mainFooterText) {
		if (StringUtils.isNotBlank(mainFooterText)) {
			Configurations.mainFooterText = mainFooterText;
		}

		if (LOG.isInfoEnabled()) {
			LOG.info("mainFooterText = " + Configurations.mainFooterText);
		}
	}

	@Override
	public void setServletContext(ServletContext servletContext) {
		Configurations.mainHeaderBackgroundUrl = servletContext.getContextPath()
				+ "/commons/styles/images/background/main-header.jpg";

		Configurations.pageIconUrl = servletContext.getContextPath()
				+ "/commons/styles/images/logo/browser_tab_logo.png";
	}
}
